home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / tpspool.com / SPOOLER.DOC < prev    next >
Encoding:
Text File  |  1990-06-14  |  13.7 KB  |  320 lines

  1.    This software is NOT freeware, and is distributed under the shareware
  2.      concept, the fee requested for useage of this software is discussed
  3.      at the end of this file (very reasonable).
  4.    It is requested that this archive be distributed as a whole,
  5.      and that all files herein be kept together.
  6.    No fee should be charged for this software beyond actual distribution
  7.      costs (connect fees, diskette costs), and should in no case exceed $10.
  8.  
  9.  
  10.    What you should find in this archive:
  11.  
  12.        SPOOLER.DOC     12417 bytes      This file.
  13.        TP55SPL.TPU     14464 bytes      Turbo Pascal 5.5 compatable unit.
  14.        TP50SPL.TPU     15216 bytes      Turbo Pascal 5.0 compatable unit.
  15.        SPLTEST.PAS      1794 bytes      Sample program using the spooler.
  16.        SPLTEST.EXE     11152 bytes      Executable version of same.
  17.  
  18.  
  19.  
  20.  
  21.  SUMMARY:
  22.      This unit implements a text file device driver (TFDD) called 'SPL'
  23.    which is designed to allow Turbo Pascal 4.0-5.5 programs to dump
  24.    text to the printer as is normally done using the 'LST' TFDD found
  25.    in the 'printer' unit which is part of Turbo Pascal, but
  26.    without arresting the operation of the program entirely until the
  27.    printing is finished.  It has been tested with Espon LX/MX/FX
  28.    printers.  By default it uses only a 16K main memory buffer, which
  29.    should be fine for most text documents of 3 pages.  If you try and
  30.    dump more than that at a time you'll have to wait. Alternatively you
  31.    can expand the main memory spooler buffer up to 65521 bytes.  If you
  32.    have Expanded memory on your computer you can install a spooler in
  33.    EMS.  It can be any size from 16K up to all of your EMS memory, at
  34.    your discretion.
  35.  
  36.  
  37.  
  38.   As indicated above there are actually 3 modes in which the spooler can
  39.    operate.
  40.     1) The default, put the spooler buffer in main memory on the Turbo
  41.        Pascal heap.  This spooler buffer can be any size between 16384 bytes
  42.        and 65521 bytes (the largest single object that can be allocated on
  43.        the TP heap).
  44.     2) If expanded memory is available, and a LIM 3.X compatable memory
  45.        manager which supports data aliasing is loaded, then a spooler buffer
  46.        between 16K and all the available expanded memory can be set up.
  47.     3) If expanded memory is not available, and regular memory is scarce,
  48.        then the spooler can be directed to dump characters directly to the
  49.        printer, as is normally done when writing to Turbo Pascal's LST
  50.        printer device.
  51.  
  52.   It should be noted that first pausing the spooler's printing out and
  53.    then overflowing the spooler buffer will likely lock up the system,
  54.    so if you pause the spooler, don't feed it any more text.
  55.  
  56.   If a print screen is in progress then this spooler will wait until it's
  57.    finished before accepting any characters to print.  So DO NOT set
  58.    the printscr bit or the system will lock up.  Also printscr is disabled
  59.    while the spooler has characters in it's buffer.
  60.  
  61.   This unit opens the printer in non-text file mode, this allows values of
  62.     26 to be sent to the printer.  When the printer is opened with the
  63.     normal text file driver, all 26's (End of File marker's in DOS) are
  64.     automatically stripped off.  If we are dumping graphics (for example)
  65.     then this is obviously undesireable.
  66.  
  67.   This software does data aliasing in expanded memory, and therefore may
  68.     not function with some types of software-only expanded memory emulators.
  69.     (It should work on all 80386 specific expanded memory emulators.)
  70.     This unit does however test for this capability and will simply
  71.     refuse to install the spooler in EMS if this capability is not
  72.     supported.  No function specific to the LIM 4.0 specification are used
  73.     so it should work with any LIM 3.X compatible memory manager.
  74.  
  75.  
  76.  
  77.   Sample useage:
  78.  
  79.     Writeln(SPL,'This is a test string.');
  80.     Writeln(SPL,'This is a combo of variables',Variable,' and strings.');
  81.     Writeln(SPL,#10#10,'This will give a couple of extra linefeeds.');
  82.  
  83. ----------------------------------------------------------------------------
  84.  
  85.   The externally visible procedures comprising this unit are:
  86.  
  87.    'SETPRINTER' - Allows you to change which printer the spooler will
  88.      send characters to, the default is LPT1.  To change to LPT2:
  89.  
  90.             SetPrinter(2);
  91.  
  92.  
  93.    'ALTERSPOOLERSIZE' - Allows you to change the default 16k spooler size.
  94.      This function has no effect unless the spooler device is closed. To
  95.      change the spooler size to 32k:
  96.  
  97.             Close(SPL);                    (* close spooler         *)
  98.             AlterSpoolerSize(32768);       (* increase spooler size *)
  99.             Rewrite(SPL);                  (* reopen spooler        *)
  100.  
  101.  
  102.    'SPOOLFUNCS' - Allows the program to directly manupulate the workings
  103.       of the spooler. It accepts an integer corresponding to the desired
  104.       function.
  105.      1: Clear the spooler.  This clears the contents of the spooling
  106.           queue, and stops the printing.
  107.      2: Pause the spooler.  This clauses the spooler to stop printing until
  108.           the 'Resume' function (function 3) is used.  This may be useful if
  109.           you are doing something that is time critical and/or should not be
  110.           interrupted until finished.  This has no effect if the spooling
  111.           is disabled (ie., printing directly to the printer).
  112.      3: Resume printing.  This cancels the pause caused by function 2.
  113.  
  114.    'SPOOLERSTATUS' - Allows the program to query the status of the spooler.
  115.       Using the 'SplStatType' declared in this unit's interface section,
  116.       the current size of the spooler can be determined ( a size of 0
  117.       indicating either that the spooler is closed, or that the spooler
  118.       is operating in the direct to printer mode (see description of
  119.       operational modes and how to change them below).  The number of bytes
  120.       left in the spooler buffer to print can be ascertained. Finally whether
  121.       the spooler is currently paused or not can be determined.
  122.  
  123.  
  124.  
  125.    The following three procedures/functions change the operating mode of
  126.     the spooler.  The spooler device which is by default open, must be closed
  127.     for any of the following to have any effect.
  128.  
  129.    'DIRECT_TO_PRINTER' - Changes the mode in which the spooler will be opened
  130.      from the current mode, to direct to printer output.  This Procedure
  131.      will have no effect if the spooler device is not closed.
  132.      EXAMPLE : If for some reason you don't want the spooler taking up main
  133.      memory, ie., you need every byte of heap space you can get your hands
  134.      on. You can close the spooler down, change the spooler to direct to
  135.      printer operation, and reopen it:
  136.  
  137.                     Close(SPL);
  138.                     Direct_To_Printer;
  139.                     Rewrite(SPL);
  140.  
  141.      This will deallocate the spooler buffer, and cause any characters
  142.      sent to the spooler to go straight to the printer instead of into the
  143.      spooler buffer.  ie., calling:
  144.  
  145.                     Writeln(SPL,' ..... ');
  146.  
  147.      will have the same effect as:
  148.  
  149.                     Writeln(LST,' ..... ');
  150.  
  151.  
  152.    'SPOOL_IN_EMS' - Changes the mode in which the spooler will be opened
  153.      from the current mode to spooling in expanded memory.  It also specifies
  154.      the size of the expanded memory buffer desired.  This function checks
  155.      to see if there is an expanded memory manager loaded, if that EMM
  156.      supports data aliasing, and if enough expanded memory exists to support
  157.      the request.  If these conditions are met, then 0 is returned, otherwise
  158.      a value of 1 is returned, and the previously assigned spooler mode
  159.      remains operational. The EMS useage in this program saves and restores
  160.      the condition of the expanded memory manager before and after use, so it
  161.      should be compatable with programs that use EMS for other purposes.
  162.      This function will fail if the spooler device is not closed.
  163.      NOTE: Spooler size is rounded up to the next largest 16K block size.
  164.      EXAMPLE: I want to allocate a 32K spooler buffer in EMS:
  165.  
  166.                      Close(SPL);
  167.                      IF Spool_In_EMS(32768) = 0 THEN
  168.                        Rewrite(SPL);
  169.  
  170.  
  171.    'SPOOL_IN_MEMORY' - Changes the mode in which the spooler will be opened
  172.      from the current mode to spooling in main memory.  As indicated above
  173.      this procedure will have no effect if the spooler device is not closed.
  174.  
  175.  
  176.  
  177.  
  178.    There are a number of cases where the calling one of the associated
  179.     spooler functions (Rewrite,Writeln,Write) can cause an error condition.
  180.     If you compile with I/O error checking off you'll be able to catch
  181.     these and prevent program termination.
  182.    Possible return codes which can occur are:
  183.  
  184.        Writeln,Write :
  185.                160 :  Out of paper, Device write fault.
  186.  
  187.        Rewrite:
  188.                1   :  Failure allocating EMS spooler.
  189.                 ( Only if you try to allocate the EMS spooler. )
  190.                203 :  If the spooler cannot allocate memory for it's buffer.
  191.                 ( Heap either too small or fragmented, main memory spooler. )
  192.  
  193.  
  194.  
  195.  
  196.  
  197.   The following is the interface for the spooler unit.
  198.   To compile this unit for Turbo Pascal 4.0 you will have to remove some
  199.         of the compiler directives which do not exist in TP 4.0.
  200.  
  201. {$A+,R-,S+,I+,D+,F-,V-,B-,N-,E-,L+,O-}
  202.  
  203. {--------------------------------------------------------------------}
  204. {---------------------------} INTERFACE {----------------------------}
  205. {--------------------------------------------------------------------}
  206.  
  207. uses CRT,DOS;
  208.  
  209. CONST
  210.   SplClear  = 1;     { Clear the spooler. }
  211.   SplPause  = 2;     { Pause the spooler's printing. }
  212.   SplResume = 3;     { Resume spooler printing. }
  213.  
  214. TYPE
  215.   SplStatType = RECORD                { Used in calls to 'SpoolerStatus'. }
  216.                   SplSize : Longint;
  217.                   BytesToPrint : Longint;
  218.                   Paused : BOOLEAN;
  219.                 END;
  220.  
  221.  
  222. VAR
  223.    SPL : TEXT;       { New text file. }
  224.  
  225.    Procedure SpoolFuncs(Operation : Integer);
  226.    Procedure SpoolerStatus(VAR Spoolstat : SplStatType);
  227.    Procedure SetPrinter(Port : BYTE);             { Change the printer spl sends to. }
  228.    Procedure AlterSpoolerSize(Size : LongInt);
  229.  
  230.    Procedure Direct_To_Printer;                   { Select Mode of Spooler. }
  231.    Function  Spool_In_EMS(Size : LongInt):Integer;
  232.    Procedure Spool_In_Memory;
  233.  
  234.  
  235. { END of interface }
  236.  
  237.  
  238.  
  239.  
  240. MORAL DOGMA
  241. ___________
  242.  
  243.  If you like this programming unit and find it useful, you are requested
  244. to support it's continued development, and the development of other
  245. useful programming tools for serious pascal developers by sending $10
  246. to the address below.  In addition to peace of mind, for your $10 you'll
  247. get the right to use this unit in your programs royalty free.  Please
  248. send postal money orders or a check drawn on a Canadian bank. (Sending
  249. cash in the mail is a bad practice.)
  250.  
  251.  Whether you decide to pony up this minor utilization fee or not, the
  252. author would appreciate any bug reports or suggestions that may
  253. be forthcoming.
  254.  
  255.  
  256.                           Douglas Webb
  257.                           228 Murray St.
  258.                           Montreal, Quebec
  259.                           H3C 2C7
  260.                           CANADA
  261.  
  262.  
  263. LEGAL DOGMA
  264. ___________
  265.  
  266.  
  267. Douglas Webb (hereafter refered to as 'the author') hereby disclaims all
  268. warranties relating to this software, whether express or implied,
  269. including without limitation any implied warranties of merchantability
  270. or fitness for a particular purpose.  The author will not be liable
  271. for any special, incidental, consequential, indirect or similar damages
  272. due to loss of data or any other reason, even if the author has been
  273. advised of the possibility of such damages.  The person using the software
  274. bears all risk as to the quality and performance of the software.
  275.  
  276. The author has done his very best to make sure that everything stated
  277. above is correct.  However, the author assumes no responsibility for errors
  278. that may appear in the descriptions of this software (although he would
  279. like to hear about them).
  280.  
  281.  
  282.  
  283. Turbo Pascal is a trademark of Borland International.
  284.  
  285.  
  286.          ----------------end-of-author's-documentation---------------
  287.  
  288.                         Software Library Information:
  289.  
  290.                    This disk copy provided as a service of
  291.  
  292.                         The Public (Software) Library
  293.  
  294.          We are not the authors of this program, nor are we associated
  295.          with the author in any way other than as a distributor of the
  296.          program in accordance with the author's terms of distribution.
  297.  
  298.          Please direct shareware payments and specific questions about
  299.          this program to the author of the program, whose name appears
  300.          elsewhere in  this documentation. If you have trouble getting
  301.          in touch with the author,  we will do whatever we can to help
  302.          you with your questions. All programs have been tested and do
  303.          run.  To report problems,  please use the form that is in the
  304.          file PROBLEM.DOC on many of our disks or in other written for-
  305.          mat with screen printouts, if possible.  The P(s)L cannot de-
  306.          bug programs over the telephone.
  307.  
  308.          Disks in the P(s)L are updated monthly, so if you did not get
  309.          this disk  directly from the P(s)L,  you should be aware that
  310.          the files in this set may no  longer be the current versions.
  311.  
  312.          For a copy of the latest monthly software library newsletter
  313.          and a list of the 2,000+ disks in the library, call or write
  314.  
  315.                         The Public (Software) Library
  316.                               P.O.Box 35705
  317.                            Houston, TX 77235-5705
  318.                                (713) 524-6394
  319.  
  320.